package com.example.gallery;

import java.io.File;

import android.content.Context;
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;

//���ۼ� : ���� > connect() > onMediaScannerConnected() > scanFile() > onScanCompleted() > disconnnect() 
public class MediaScanner implements MediaScannerConnectionClient{
	String TAG = "MediaScanner";
	private MediaScannerConnection ms;
	private File file;
	final String path = Environment.DIRECTORY_DCIM;
	
	
	public MediaScanner() {
		
	}

	public MediaScanner(Context ctx, File image_file){
		file = image_file;
		ms = new MediaScannerConnection(ctx, this);
		ms.connect();
	}
	
	public String getAlbum(){
		Log.i(TAG, path );
		return path;
	}
	@Override
	public void onMediaScannerConnected() {
		ms.scanFile(file.getAbsolutePath(), null);
	}

	@Override
	public void onScanCompleted(String path, Uri uri) {
		ms.disconnect();
	}
	

}
